package Library.operation;

import Library.book.Book;
import Library.book.BookList;

import java.util.Scanner;
public class FindOperation implements IOperation{
    public void work(BookList bookList){
        Scanner scanner = new Scanner(System.in);
        System.out.println("查找图书");
        System.out.println("请输入图书的名称：");
        String name = scanner.next();
        for (int i = 0; i < bookList.getUsedSize(); i++) {
            Book book = bookList.getBook(i);
            if (book.getName().equals(name)){
                System.out.println("找到该图书！");
                System.out.println(book);
                return;
            }
        }
        System.out.println("对不起，没有找到此书！");
    }
}
